package com.code.splider.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

import com.code.splider.service.HistoryScoreService;

@Service("historyScoreService")
public class HistoryScoreServiceImpl implements HistoryScoreService{

	private void getScore(String url){
		Connection conn = Jsoup.connect(url);
		Elements el = null;
		try {
			Map<String, List<String>> map = new TreeMap<String, List<String>>();
			Document doc = conn.get();
			el = doc.getElementsByAttributeValue("class", "small-6 columns PL0");
			int i = 1;
			for (Element element : el) {
				Elements buttons = element.select("a");
				for (Element element2 : buttons) {
					System.out.println(element2);
					i++;
				}
			}
			System.out.println(i);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		HistoryScoreServiceImpl ls = new HistoryScoreServiceImpl();
		String url = "http://www.dszuqiu.com/race_ls/238485";
		ls.getScore(url);
	}
}
